Skip to content

Migrate to modern Python tooling (uv, pyproject.toml, semantic-release) - #2423

Open
salman2013 wants to merge 9 commits into
openedx:masterfrom
salman2013:modernize-python-tooling
Open

salman2013 wants to merge 9 commits into
openedx:masterfrom
salman2013:modernize-python-tooling

Conversation

@salman2013

@salman2013 salman2013 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Phase 1 — Consolidate all package metadata into `pyproject.toml` (PEP 621): static dependencies, SPDX license, setuptools-scm for dynamic versioning, coverage config, isort config; delete `setup.py`, `setup.cfg`, `.coveragerc`
  • Phase 2 — Replace pip-tools with uv: `[dependency-groups]` (PEP 735), `uv.lock`, updated `tox.ini` to use `tox-uv` + `uv-venv-lock-runner`, updated `Makefile` and CI workflow to use `uv sync`/`uv run tox`
  • Phase 3 — Add `python-semantic-release` for automated versioning and PyPI publishing via OIDC trusted publisher; delete legacy `pypi-publish.yml`
  • Phase 4 — Migrate to `src/` layout: move `openassessment/` → `src/openassessment/`, add `where = ["src"]` to `pyproject.toml`, update Makefile, scripts, MANIFEST.in, and karma.conf.js paths

Test plan

  • CI passes on this PR (`django42`, `django52`, `js`, `quality` environments)
  • Configure OIDC trusted publisher on PyPI for `openedx/edx-ora2` → workflow `release.yml` before merging

🤖 Generated with Claude Code

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 17, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @salman2013!

This repository is currently maintained by @openedx/openedx-unmaintained.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the core contributor PR author is a Core Contributor (who may or may not have write access to this repo). label Jul 17, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.53%. Comparing base (1b7ae59) to head (b729162).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2423      +/-   ##
==========================================
+ Coverage   95.46%   95.53%   +0.06%     
==========================================
  Files         198      198              
  Lines       22842    22820      -22     
  Branches     1551     1549       -2     
==========================================
- Hits        21807    21801       -6     
+ Misses        780      765      -15     
+ Partials      255      254       -1     
Flag Coverage Δ
unittests 95.53% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@salman2013
salman2013 force-pushed the modernize-python-tooling branch from d6b467b to 5ae0ab5 Compare July 20, 2026 11:45
@itsjeyd itsjeyd moved this from Needs Triage to Waiting on Author in Contributions Jul 28, 2026
@itsjeyd

itsjeyd commented Jul 28, 2026

Copy link
Copy Markdown

Hi @salman2013, thank you for your contribution! Please let us know when it is ready for review.

@salman2013 salman2013 changed the title chore: migrate to modern Python tooling (uv, pyproject.toml, semantic-release, src layout) Migrate to modern Python tooling (uv, pyproject.toml, semantic-release, src layout) Sep 2, 2026
@salman2013
salman2013 force-pushed the modernize-python-tooling branch 3 times, most recently from 13c9e99 to 7d5e631 Compare September 2, 2026 08:52
Comment thread pyproject.toml
Comment thread pyproject.toml
readme = "README.rst"
license = "AGPL-3.0-only"
license-files = ["LICENSE"]
authors = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as acid-block#282: {name = "edX", email = "oscm@edx.org"} is the legacy convention. This migration effort has standardized on {name = "Open edX Project", email = "oscm@openedx.org"}, matching sample-plugin's actual current pyproject.toml.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't look addressed yet — pyproject.toml still has {name = "edX", email = "oscm@edx.org"}. Please update to {name = "Open edX Project", email = "oscm@openedx.org"} per the migration convention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed — pyproject.toml now has {name = "Open edX Project", email = "oscm@openedx.org"}. Thanks for the fix. Resolving.

Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/ci.yml
@salman2013 salman2013 changed the title Migrate to modern Python tooling (uv, pyproject.toml, semantic-release, src layout) Migrate to modern Python tooling (uv, pyproject.toml, semantic-release) Sep 8, 2026
@itsjeyd itsjeyd moved this from Waiting on Author to In Eng Review in Contributions Sep 15, 2026
@itsjeyd itsjeyd added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Sep 15, 2026
@itsjeyd

itsjeyd commented Sep 15, 2026

Copy link
Copy Markdown

Hi @salman2013, it looks like one of the coverage checks is failing here. Could you have a look?

…ntic-release)

- Migrate to src layout (src/openassessment/)
- Adopt uv for dependency management with pyproject.toml
- Add tox environments: docs, quality; update js env to django42
- Integrate python-semantic-release for automated versioning
- Update release workflow with immutable releases strategy and bumped action versions
- Fix i18n_tool, webpack, and eslint paths for src layout
- Update author to Open edX Project convention
- Add docs tox env with doc8, build, and twine checks
- Switch coverage to source_pkgs; add pragma: no cover to __version__

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salman2013
salman2013 force-pushed the modernize-python-tooling branch from 030f813 to 199dc30 Compare September 17, 2026 11:16
salman2013 and others added 4 commits September 17, 2026 16:24
…tooling

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/pypi-publish.yml
#	openassessment/__init__.py
The omit pattern 'openassessment/runtime_imports/*' no longer matches
'src/openassessment/runtime_imports/*' after the src layout migration.
Use '*/runtime_imports/*' to match regardless of path prefix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Change --cov target from 'openassessment' to 'src/openassessment' so
  pytest-cov finds the package after the src layout migration
- Add 'build' to norecursedirs to prevent stale build artifacts from
  being collected by pytest
- Remove */tests/*, */__pycache__/*, */settings.py from coverage omit
  to match original .coveragerc behaviour; omitting in-package test
  files (100% covered) was artificially lowering the project coverage %

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds lock entries for build, doc8, twine and their transitive
dependencies introduced in the doc dependency group.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@salman2013

Copy link
Copy Markdown
Contributor Author

@itsjeyd All tests are green now.

@itsjeyd

itsjeyd commented Sep 22, 2026

Copy link
Copy Markdown

Thanks @salman2013.

@openedx/axim-engineering Pinging you here since this repo is currently unmaintained.

This PR got approval from a CC earlier (#2423 (review)) and has a green build. Could you please have a look and merge the changes if they look good to you as well?

@itsjeyd itsjeyd added waiting for eng review PR is ready for review. Review and merge it, or suggest changes. and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Sep 22, 2026
Comment thread pyproject.toml Outdated

[tool.setuptools.package-data]
# locale/ is a symlink to conf/locale/ — include the real path instead
# (setuptools cannot copy symlinked directories into the wheel)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python -m build --wheel fails on this branch:

error: can't copy 'src/openassessment/locale': doesn't exist or not a regular file

src/openassessment/locale is a git-tracked symlink to conf/locale, and setuptools-scm's file finder puts every git-tracked path into SOURCES.txt, so build_py tries to copy the symlink as a file. origin/master builds fine. PSR runs build_command before it commits or tags, so the first push to master after this merges fails there and no version publishes.

The comment here is wrong too. MANIFEST.in's recursive-include src/openassessment/locale *.mo does copy through the symlink: published 7.1.1 and a build off this branch both carry the same 77 .mo files under openassessment/locale/, so conf/locale/** only adds a second copy of them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread pyproject.toml Outdated
[tool.setuptools.packages.find]
where = ["src"]
include = ["openassessment*"]
exclude = ["*.tests", "*.tests.*"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the build is fixed the wheel is 957 files / 4,878,011 bytes, against 466 / 2,601,590 for PyPI 7.1.1. Nothing that shipped before is dropped. What is new is 154 duplicate locale files under openassessment/conf/locale/, 191 test and spec files including 101 fixtures under openassessment/xblock/test/data, and the sass sources, xblock/static/xml and the font-awesome fonts.

include-package-data defaults to true under pyproject.toml, and with setuptools-scm's file finder that means every git-tracked file under a package directory, so neither MANIFEST.in nor [tool.setuptools.package-data] bounds the wheel any more. Widening this exclude to cover *.test is not enough on its own; I tried it and the files still ship as package data of the parent package.

Get the wheel back to what 7.1.1 shipped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread .github/workflows/ci.yml
contents: read
strategy:
fail-fast: false
matrix:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs is in the tox envlist but not in this matrix, and it is red: tox -e docs stops at doc8 docs/ with 105 errors across 8 files. That env is the only place that runs python -m build --wheel and twine check, which is what would have caught the wheel not building.

Add docs to the matrix and fix the doc8 failures.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -0,0 +1,121 @@
name: Semantic Release

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.github/release_process.md still says to bump the version in openassessment/__init__.py and package.json and then hand-create a matching release tag. That path no longer exists, the Python version comes from git tags now, and semantic-release creates the tag. Update it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@itsjeyd itsjeyd added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Sep 29, 2026
salman2013 and others added 4 commits October 6, 2026 15:44
… extra files

Setuptools' include-package-data default of true, combined with
setuptools-scm's git-tracked-file finder, pulled every git-tracked path
under openassessment/ into the wheel: the bare src/openassessment/locale
symlink crashed `python -m build --wheel` ("can't copy ... doesn't exist
or not a regular file"), and test/spec packages, duplicate locale files,
sass sources, static/xml fixtures, and font-awesome fonts all shipped
alongside it.

Set include-package-data = false so package-data/exclude-package-data
fully control wheel contents again, replace the conf/locale/** package
data (which only duplicated the real locale files) with explicit
locale/**/*.po and *.mo globs matching MANIFEST.in, and extend the
packages.find exclude to also match singular "test" packages (some
subpackages use "test", others "tests"). Verified the resulting wheel
is file-list-identical to the published 7.1.1 release.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The docs tox env (doc8, wheel build + twine check, Sphinx build) was
never wired into CI, so it had drifted to 105 doc8 violations -
trailing whitespace and lines over the 79-char limit - across 7 rst
files, plus a couple of RST list/indentation issues. Reflow the long
prose lines and strip trailing whitespace without changing content, add
docs to the CI matrix, and gitignore the generated docs/_build/ output
so it doesn't get swept into local doc8 runs. Verified `tox -e docs`
passes end-to-end.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Both release_process docs still described bumping the version by hand
in openassessment/__init__.py and package.json, then manually tagging a
GitHub release. That path no longer exists: python-semantic-release now
reads Conventional Commits messages to pick the next version, tags it,
and publishes it via .github/workflows/release.yml. Update both docs to
describe that flow instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tooling

Keeps the legacy pip-tools requirements/*.txt, openassessment/__init__.py
version string, and .github/workflows/pypi-publish.yml deleted, since
they're superseded by uv.lock, setuptools-scm, and release.yml
respectively.

Resolves the ci.yml/tox.ini conflict by dropping the django42 tox
env/CI matrix entry/pyproject.toml dependency group, matching upstream's
openedx#2424 decision to only test Django 5.2 going forward, and switches the
js tox env to the "test" dependency group now that django42 is gone.

Upgrades edx-lint (6.1.0 -> 6.2.0) and djangorestframework (3.17.1 ->
3.18.1) in uv.lock to match the versions upstream's own requirements
upgrade already validated and wrote pylintrc/test fixes against.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@salman2013
salman2013 requested a review from feanil October 6, 2026 10:58
@itsjeyd itsjeyd added waiting for eng review PR is ready for review. Review and merge it, or suggest changes. and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 6, 2026
Comment thread docs/release_process.rst
Comment on lines +94 to 96
- create a corresponding release on GitHub:
https://github.com/openedx/edx-ora2/releases

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- create a corresponding release on GitHub:
https://github.com/openedx/edx-ora2/releases

The Semantic Release workflow creates the GitHub release now, so this step is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U waiting for eng review PR is ready for review. Review and merge it, or suggest changes.

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

5 participants